
--Alter table to allow null
ALTER TABLE Family ALTER COLUMN OwnerId INTEGER NULL
GO

--Alter table to allow null
ALTER TABLE [User] ALTER COLUMN AddedUserId INTEGER NULL
GO

--Update the table, set null to not null fields.
UPDATE Family SET OwnerId = NULL WHERE OwnerId IS NOT NULL
GO

--Delete the existing values to avoid conflicts.
DELETE FROM RationCardAlterRequest
DELETE FROM RationCardAlterRequestType
DELETE FROM Unsubscription
DELETE FROM UnsubscriptionType
DELETE FROM BirthCertificate
DELETE FROM BirthReport
DELETE FROM RationCard
DELETE FROM VoterCard
DELETE FROM [User]
DELETE FROM Family
DELETE FROM Roles
DELETE FROM PermanentAddress
DELETE FROM District
DELETE FROM State

--Insert values to State
DBCC CHECKIDENT (State, RESEED, 0)
GO

INSERT INTO State(StateName)
	VALUES('')
GO
INSERT INTO State(StateName)
	VALUES('Karnataka')
GO
INSERT INTO State(StateName)
	VALUES('Andhra Pradesh')

GO

INSERT INTO State(StateName)
	VALUES('Arunachal Pradesh')
GO
INSERT INTO State(StateName)
	VALUES('Assam ')
GO
INSERT INTO State(StateName)
	VALUES('Bihar 	')
	
GO
INSERT INTO State(StateName)
	VALUES('Chhattisgarh')
	
GO

INSERT INTO State(StateName)
	VALUES('Goa' )
GO
INSERT INTO State(StateName)
	VALUES('Gujarat')
GO
INSERT INTO State(StateName)
	VALUES('Haryana')
GO
INSERT INTO State(StateName)
	VALUES('Himachal Pradesh')
GO
INSERT INTO State(StateName)
	VALUES('Jammu and Kashmir')
GO

INSERT INTO State(StateName)
	VALUES('Jharkhand ')
GO

INSERT INTO State(StateName)
	VALUES('Kerala')
GO

INSERT INTO State(StateName)
	VALUES('Madhya Pradesh ')
GO

INSERT INTO State(StateName)
	VALUES('Maharashtra ')
GO

INSERT INTO State(StateName)
	VALUES('Manipur')
GO

INSERT INTO State(StateName)
	VALUES('Meghalay')
GO

INSERT INTO State(StateName)
	VALUES('Mizoram')
GO

INSERT INTO State(StateName)
	VALUES('Nagaland')
GO

INSERT INTO State(StateName)
	VALUES('Orissa')
GO

INSERT INTO State(StateName)
	VALUES('Punjab')
GO

INSERT INTO State(StateName)
	VALUES('Rajasthan ')
GO

INSERT INTO State(StateName)
	VALUES('Rajasthan')
GO

INSERT INTO State(StateName)
	VALUES('Tamil Nadu')
GO

INSERT INTO State(StateName)
	VALUES('Tripura')
GO

INSERT INTO State(StateName)
	VALUES('Uttar Pradesh')
GO

INSERT INTO State(StateName)
	VALUES('Uttarakhand')
GO

INSERT INTO State(StateName)
	VALUES('West Bengal')
GO

INSERT INTO State(StateName)
	VALUES('Andaman and Nicobar')
GO

INSERT INTO State(StateName)
	VALUES('Chandigarh ')
GO

INSERT INTO State(StateName)
	VALUES('Dadra and Nagar Haveli')
GO

INSERT INTO State(StateName)
	VALUES('Daman and Diu')
GO

INSERT INTO State(StateName)
	VALUES('Lakshadweep')
GO

INSERT INTO State(StateName)
	VALUES('Puducherry')
GO

--Alter table to not allow null
ALTER TABLE Family ALTER COLUMN OwnerId INTEGER NOT NULL
GO

--Alter tables to not allow null
ALTER TABLE [User] ALTER COLUMN AddedUserId INTEGER NOT NULL
GO